<?php
/**
 * Joomla! 1.5 component ArticleCashRewards
 *
 * @version $Id: view.html.php 2009-05-10 01:47:01 svn $
 * @author Maverick
 * @package views.weblinks
 * @subpackage ArticleCashRewards
 * @license GNU/GPL
 * Website: http://www.boddunan.com
 *
 * Review and approve the articles and assign points and cash rewards.
 * Users can see their articles and the points/cash rewards assigned in the front-end module.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class ArticleCashRewardsViewReferrals extends JView {
	
    function display($tpl = null) {
		
		JToolBarHelper::title("&nbsp;&nbsp;&nbsp;&nbsp;" . JText::_('ArticleCashRewards').': <small><small>[ ' . JText::_('CPANEL_REFERRALS') .' ]</small></small>', 'acr-48.png');
		JToolBarHelper::custom('cpanel', 'default.png', 'default.png', JText::_('TITLE_CPANEL'), false);    
		$params 	= JComponentHelper::getParams('com_articlecashrewards');
		$this->assignRef('params', $params);
        $model = $this->getModel('referrals');
        
        if($this->getLayout() == 'levels'){
            JToolBarHelper::custom('publishLevel', 'publish.png', 'publish.png', 'TITLE_PUBLISH', true);
            JToolBarHelper::custom('unpublishLevel', 'unpublish.png', 'unpublish.png', JText::_('TITLE_UNPUBLISH'), true);
            JToolBarHelper::custom('removeLevel', 'delete.png', 'delete.png', JText::_('TITLE_REMOVE'), true);

            $cid = JRequest::getVar('cid', null);
            $redirect = JRequest::getVar('redirect', '0');
            $rows = $model->getLevels();
            $pagination = $model->getPagination();

            $this->assignRef('rows', $rows);
            $this->assignRef('pagination', $pagination);
            JToolBarHelper::preferences('com_articlecashrewards', '250');
            parent::display($tpl);
        }else if($this->getLayout() == 'pending'){

            JToolBarHelper::custom('approvePayments', 'publish.png', 'publish.png', JText::_('TITLE_APPROVE'), true);
            JToolBarHelper::custom('disapprovePayments', 'unpublish.png', 'unpublish.png', JText::_('TITLE_DISAPPROVE'), true);
            
            $rows = $model->getReferralReports('0');
            $pagination = $model->getPagination();

            $this->assignRef('result', $rows);
            $this->assignRef('pagination', $pagination);
            parent::display($tpl);
        }else if($this->getLayout() == 'reviewed'){

            JToolBarHelper::custom('approvePayments', 'publish.png', 'publish.png', JText::_('TITLE_APPROVE'), true);
            JToolBarHelper::custom('disapprovePayments', 'unpublish.png', 'unpublish.png', JText::_('TITLE_DISAPPROVE'), true);

            $rows = $model->getReferralReports('1,2');
            $pagination = $model->getPagination();

            $this->assignRef('result', $rows);
            $this->assignRef('pagination', $pagination);
            parent::display($tpl);
        }else{

            parent::display($tpl);
        }
    }
}
?>